package com.lwl.blue.commont.utils;

import com.lwl.blue.commont.enums.ExcelTemplateEnum;
import com.lwl.blue.commont.enums.FileUploadTypeEnum;
import org.springframework.beans.factory.annotation.Value;

import java.io.File;

/**
 * <p> excel模板工具类 </p>
 *
 * @Date: 2021/11/30 16:19
 * @version: V1.0
 * @Decription:
 * @author: 蓝文良
 */
public class ExcelTemplateUtil {
    @Value("${upload.filePath}")
    private String filePath;
    /**
     * 获取模板文件路径
     * @param templateEnum
     * @return
     */
    public static String getExcelTemplatePath(ExcelTemplateEnum templateEnum){
        String file1 = ExcelTemplateUtil.class.getClassLoader().getResource("").getFile();
        file1=file1.substring(1)+templateEnum.getPath();
        return file1;
    }

    /**
     * 获取报价单模板文件路径
     * @param customerId
     * @return
     */
    public static String getQuotationExcelTemplatePathByCustomerId(String filePath,Integer customerId){
        return filePath+FileUploadTypeEnum.QUOTATION_TEMPLATE.getType() + "/" +  customerId + ".xlsx";
    }

    public static void main(String[] args) {
        String excelTemplatePath = ExcelTemplateUtil.getExcelTemplatePath(ExcelTemplateEnum.CONTRACT_SUPPLIER);
        System.out.println(excelTemplatePath);
    }
}
